﻿using Microsoft.UI.Xaml.Data;

namespace DimensionsHelper.Client.WinUi.Helpers;

public partial class ColorToSolidBrushConverter : IValueConverter
{
    public Color TreatAsTransparent
    {
        get;
        set;
    }


    public object Convert(object value, Type targetType, object parameter, string language)
    {
        if (value is Color color)
        {
            return new SolidColorBrush(color == TreatAsTransparent ? Colors.Transparent : color);
        }

        return new SolidColorBrush();
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        if (value is SolidColorBrush solidColorBrush)
        {
            return solidColorBrush.Color == TreatAsTransparent ? Colors.Transparent : solidColorBrush.Color;
        }

        return Colors.Transparent;
    }
}